﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Summerset.Isbndb.Subjects
{

    /// <summary>
    /// The 'subjects' collection provides information about book subjects. 
    /// To retrieve corresponding books you can use 'subject_id' to search in the books collection.
    /// </summary>
    public static class SubjectArgs
    {

        /// <summary>
        /// Gets an array of strings containing the valid indexes for the Authors collection.
        /// </summary>
        public static string[] GetValidIndexArguments()
        {

            return typeof(Arguments)
                .GetFields(BindingFlags.Public | BindingFlags.Static)
                .Select(fi => fi.GetRawConstantValue().ToString())
                .ToArray();

        }

        /// <summary>
        /// Gets an array of strings that contain the additional results that can be requested from the subjects collection.
        /// </summary> 
        public static string[] GetValidResultArguments()
        {

            return typeof(Results)
                .GetFields(BindingFlags.Public | BindingFlags.Static)
                .Select(fi => fi.GetRawConstantValue().ToString())
                .ToArray();

        }


        /// <summary>
        /// Contains the possible indexes that can be queried from the subjects collection.
        /// One of these constants must be provided to the <see cref="SubjectsRequest"/> constructor.
        /// </summary>
        public static class Arguments
        {

            /// <summary>
            /// Performs a search on the subject name.
            /// </summary>
            /// <remarks>
            /// The search follows the same rules and syntax as the search on the website itself -- you can group words together using double quotes, 
            /// all non-ignored words must be present in the results.
            /// </remarks>
            public const string name = "name";

            /// <summary>
            /// Retrieving subjects listed in the given category by that category ID.
            /// </summary>
            public const string category_id = "category_id";

            /// <summary>
            /// Retrieving subject data by ISBNdb.com's subject ID. Returns at most one match.
            /// </summary>
            public const string subject_id = "subject_id";
        }

        /// <summary>
        /// Contains optional arguments that can be provided to the <see cref="SubjectsRequest"/> constructor.        
        /// </summary>
        public static class Results
        {
            /// <summary>
            /// Shows a list of categories this subject is listed in.
            /// </summary>
            public const string categories = "categories";

            /// <summary>
            /// Shows what the subject consists of.
            /// </summary>
            /// <remarks>
            /// Attributes in the SubjectData tag have the following meaning:
            /// marc_field - where available this represents the value corresponding to MARC standard. See http://www.loc.gov/marc/bibliographic/ecbdhome.html for details.
            /// marc_indicator_1 and marc_indicator_2 - two characters from this MARC record's indicator columns, where available.
            /// Attributes in the SubjectElement tag have the following meaning:
            /// text - literal text of the subject element. Typically, but not in all cases, subject name is formed by combining texts of its elements separated by double-dash.
            /// type - an ISBNdb.com specific type loosely based on the MARC field and subfield information.
            /// marc_subfield - MARC subfield symbol, where available.
            /// </remarks>
            public const string structure = "structure";
        }

    }
}
